package practice;

import java.nio.file.spi.FileSystemProvider;
import java.util.Random;
import java.util.Scanner;

public class Demo {

	public static void main(String[] args) {
		int resultNumber = DoubleColorBall_number();
		System.out.println(resultNumber);
		int customerNum = buy();
		System.out.println(customerNum);
		if(customerNum == resultNumber) {
			System.out.println("恭喜你中奖了！");
		}
		else {
			System.out.println("就你这非洲人还想撞大运");
		}

	}

	// 随机生成一个双色球号码
	public static int DoubleColorBall_number() {
		
		//7位数随机生成
        Random num = new Random();
        int number = Math.abs(num.nextInt(10000000));
        return number;
	}
	//顾客购买的情况
	public static int buy() {
		System.out.println("请从红球1-33中随机选出六个不同的号码");
		Scanner input = new Scanner(System.in);
		int []number = new int[7];
		for(int i=0;i<6;i++) {
			int n = i;
			int ret = input.nextInt();
			if(ret<34&&ret>0) {
				number[i] = ret;
			}
			else {
				System.out.println("您输入的数字有误，请重新输入");
				i -= 1;
			}
			
		}
		System.out.println("请从蓝球1-16中随机选出一个");
		for(int i=0;i<1;i++) {
			int ret = input.nextInt();
			if(ret<17&&ret>0) {
				number[6] = ret;
			}
			else {
				System.out.println("您输入的数字有误，请重新输入");
				i -= 1;
			}
		}
		//从数组中读取数据并生成对应的号码
		int result = 0;
		for(int i=6,multiple=1;i>=0;i--) {
			int ret = number[i];
			ret = ret%10;
			result += ret*multiple;
			multiple *= 10;
		}
		return result;
		
	}

}
